import React from 'react'
import { useLocation,useParams } from 'react-router-dom'
import qs from 'qs'
export default function News() {
    const location = useLocation()
    const {
        user,
        age
    } =qs.parse(location.search.split('?')[1])
    const newList = location.state
    const {id} =useParams()

  return (
    <div>
            <p>新闻id{id}</p>
            <p>名字{user}，年龄{age}</p>
            <ul>
                {
                    newList.map(item=><li key={item.id}>{item.name}</li>)
                }
            </ul>
     </div>
  )
}
